import Vue from 'vue';
import Vuex from 'vuex';
import {stage} from '@store/stage';

Vue.use(Vuex);
export default new Vuex.Store({
	state: {version: '1.20.910', mathData: '', mathImg: {}, theme: '', canvasBase64: ''},
	modules: {stage},
	strict: true,
	getters: {
		getMathData(state:any) :string {
			return state.mathData
		},
		getMathImg(state:any) :string {
			return state.mathImg
		},
		getTheme(state:any) :string {
			return state.theme
		},
		getCanvasBase64(state:any) :string {
			return state.canvasBase64
		}
	},
	mutations: {
		setMathDataMu(state:any, val:string): void {
			state.mathData = val;
		},
		setMathImgMu(state:any, val:string): void {
			state.mathImg = val;
		},
		setThemeMu(state:any, val:string): void {
			state.theme = val;
		},
		setCanvasBase64Mu(state:any, val:string): void {
			state.canvasBase64 = val;
		}
	},
	actions: {
		setMathData({commit}:any, val:string): void {
			commit('setMathDataMu', val)
		},
		setMathImg({commit}:any, val:string): void {
			commit('setMathImgMu', val)
		},
		setTheme({commit}:any, val:string): void{
			commit('setThemeMu', val)
		},
		setCanvasBase64({commit}:any, val:string): void{
			commit('setCanvasBase64Mu', val)
		}
	}
});
